#include "pageswitchbutton.h"

pageSwitchButton::pageSwitchButton(QWidget *parent)
{
    setFixedSize(48,46);
    image = new QLabel(this);
    image->setGeometry((48-24)/2,0,24,24);
    text = new QLabel(this);
    text->setGeometry(0,30,49,16);
    setTextColor("#999999");
}

void pageSwitchButton::setImageAndText(const QString &image_path,const QString &text_content,int page_id)
{
    text->setText(text_content);
    text->move((48-text_content.size()*12)/2, 30);
    image->setPixmap(image_path);
    this->page_id = page_id;
}

void pageSwitchButton::setImage(const QString &image_path)
{
    image->setPixmap(image_path);
}

void pageSwitchButton::setTextColor(const QString &color)
{
    text->setStyleSheet("font-family: 微软雅⿊;"
                        "font-size: 12px;"
                        "font-style: normal;"
                        "font-weight:bold;"
                        "color:"+color+';');
}

int pageSwitchButton::getPageID() const
{
    return page_id;
}

void pageSwitchButton::mousePressEvent(QMouseEvent *event)
{
    setTextColor("#000000");
    emit(switchPage(page_id));
}
